<template>
	<div class="main-content">
		<div class="screen-frame clearfix">
			<ul class="premises-details">
				<li class="col-sm-12 col-md-6">
					<div class="list-info-template">
						<div class="control-details">
							<input type="text" class="form-control" placeholder="楼盘名称" v-model="params.name">
							<button class="btn btn-theme searchBtn" @click="dynamicList" v-res="{code:'menu_0004_0002_0004'}">搜索</button>
							<button class="btn btn-theme searchBtn" style="margin-left: 80px;display: inline-block;" @click="addDynamic" v-res="{code:'menu_0004_0002_0003'}">添加动态</button>
						</div>
					</div>
				</li>
			</ul>

		</div>
		<div class="table-responsive report-table">
			<table class="table table-striped table-bordered min-width-1060">
				<thead>
					<tr>
						<th width="5%">序号</th>
						<th width="15%">楼盘名称</th>
						<th width="40%">楼盘动态</th>
						<th width="15%">创建时间</th>
						<th width="10%">操作</th>
					</tr>
				</thead>
				<tbody>
					<tr v-for="(row, index) in pageList">
						<td>{{index+1}}</td>
						<td style=" text-align: left">
							{{row.premisesName}}
                            <span v-if="row.isBindingV10 === '已推送' " style="background:#f6ffed;padding: 2px 8px;line-height: 20px;border-radius: 3px;
                                marginLeft: 5px;width:60px; color:#19be6b; border:1px solid #b7eb8f">{{row.isBindingV10}}</span>
                        </td>
						<td class="dynamic" style="text-align: left;">{{row.title}}</td>
						<td>{{(row.updateTime!=null)?row.updateTime:row.createTime}}</td>
						<td>
							<a @click="toDynamicDetail(row.id)" class="btnA edit" v-res="{code:'menu_0004_0002_0001'}">查看</a>
							<a @click="toDynamicEdit(row.id)" class="btnA edit" v-res="{code:'menu_0004_0002_0002'}">&nbsp 编辑</a>
						</td>
					</tr>
				</tbody>
			</table>
		</div>
		<div id="laypage_premises_dynamic"></div>
	</div>
</template>

<script>
	export default {
		name: 'dynamic',
		data() {
			return {
				params: {
					pageSize: 10,
					pageNo: 1,
					name: '',
				},
				pageList: []
			}
		},
		components: {},
		mounted: function() {
			this.dynamicList();
		},
		methods: {
			dynamicList() {
				var _self = this;
				var body = {};
				body.params = _self.params;
				var url = _self.utilHelper.apiUrl + "/api/getPremisesDynamicPage";
				this.$http.post(url, body).then((response) => {
					var body = response.body.resData;
					if(body.result == "1") {
						var resData = body.premisesDynamicList;
						var totalPages = resData.totalPages;
						var total = resData.total;
						var current = resData.pageNumber;
						_self.pageList = resData.rows;
						//加载分页组件
						if(totalPages > 0) {
							layui.laypage.render({
								elem: $('#laypage_premises_dynamic'), //容器。值支持id名、原生dom对象，jquery对象,
								limit:_self.params.pageSize,
								curr:_self.params.pageNo,
								count:total,
								theme: '#f87242;', //皮肤
								first: '首页', //若不显示，设置false即可
								last: '尾页', //若不显示，设置false即可
								prev: '上一页', //若不显示，设置false即可
								next: '下一页', //若不显示，设置false即可
								layout:['prev', 'page', 'next','skip','count'],
									jump: function(obj, first) {
										if(!first) {
											_self.params.pageNo = obj.curr;
											_self.dynamicList();
										}
									}
							});
						}
					}
				}, (response) => {
					console.log(response);
				});
			},toDynamicEdit(id) {
				this.$router.push({
					path: '/premisesDynamicEdit/'+id
				})
			},toDynamicDetail(id) {
				this.$router.push({
					path: '/premisesDynamicDetail/'+id
				})
			},addDynamic() {
				this.$router.push({
					path: '/premisesDynamicAdd'
				})
			}
		}
	}
</script>